﻿<!-- Copyright 2012-2017 Dmitry Kischenko

Licensed under the Apache License, Version 2.0 (the "License"); 
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied. 
See the License for the specific language governing permissions and 
limitations under the License. -->
<UserControl x:Class="xFunc.Views.GraphsControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:views="clr-namespace:xFunc.Views"
             xmlns:fluent="urn:fluent-ribbon"
             xmlns:res="clr-namespace:xFunc.Resources"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignWidth="640" d:DesignHeight="360">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="4*" />
        </Grid.ColumnDefinitions>

        <Border Grid.Column="0" BorderBrush="Black" BorderThickness="0,0,1,0">
            <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                <StackPanel Margin="6,4,8,4">
                    <TextBlock Text="{x:Static res:Resource.ExpressionsTextBox}" FontSize="14" />
                    <ListBox x:Name="graphsList" BorderBrush="Transparent" BorderThickness="0" ItemContainerStyle="{StaticResource listBoxItemStyle}" Background="White" SelectionChanged="graphsList_SelectionChanged">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>

                                    <CheckBox Grid.Column="0" IsChecked="{Binding Path=IsChecked}" HorizontalAlignment="Center" VerticalAlignment="Center" Checked="graphItem_Toggle" Unchecked="graphItem_Toggle" />
                                    <TextBlock Grid.Column="1" Text="{Binding}" FontSize="14" Margin="4,0,0,0" />
                                    <fluent:DropDownButton Grid.Column="2" HorizontalAlignment="Left" SizeDefinition="Small">
                                        <fluent:DropDownButton.Icon>
                                            <Rectangle VerticalAlignment="Bottom" Height="16" Width="16" HorizontalAlignment="Center">
                                                <Rectangle.Fill>
                                                    <SolidColorBrush Color="{Binding Path=ChartColor, Mode=TwoWay}" />
                                                </Rectangle.Fill>
                                            </Rectangle>
                                        </fluent:DropDownButton.Icon>
                                        <fluent:ColorGallery IsAutomaticColorButtonVisible="False" IsNoColorButtonVisible="False" SelectedColor="{Binding Path=ChartColor, Mode=TwoWay}" />
                                    </fluent:DropDownButton>
                                    <Button Grid.Column="3" Width="16" Height="16" Style="{StaticResource buttonStyle}" BorderThickness="0" Tag="{Binding}" Click="removeGraph_Click">
                                        <Viewbox>
                                            <TextBlock>✕</TextBlock>
                                        </Viewbox>
                                    </Button>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <TextBox x:Name="graphExpressionBox" FontSize="14" Foreground="Black" TextWrapping="Wrap" Height="Auto" Margin="0,4,0,0" KeyUp="graphExpBox_KeyUp" />
                </StackPanel>
            </ScrollViewer>
        </Border>
        <views:PlottingGraph x:Name="plot" Grid.Column="1" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" />
    </Grid>
</UserControl>
